package com.mingmen.canting.chushizhang;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mingmen.canting.R;
import com.mingmen.canting.adapter.SecondAdapter;
import com.mingmen.canting.model.ShopListModel;
import com.mingmen.canting.model.SimpleData;

import java.util.ArrayList;
import java.util.List;


public class CaiGouDanRightdapter extends RecyclerView.Adapter<CaiGouDanRightdapter.ViewHolder> {
    List<String> myLiveList;
    Context mContext;
    private OnItemClickListener mOnItemClickListener;


    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.mOnItemClickListener = onItemClickListener;
    }

    public interface OnItemClickListener {
        void onItemClickListener(View view, int pos, List<ShopListModel.DataBean> myLiveList);
    }


    public CaiGouDanRightdapter(Context context, List<String> list) {
        this.mContext = context;
        this.myLiveList = list;

    }

    public void setDataList(List<String> list) {
        myLiveList = list;

        notifyDataSetChanged();
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_caigou_right, parent, false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    int mycount = 0;

    @Override
    public void onBindViewHolder(final ViewHolder holder, final int position) {
//        ShopListModel.DataBean myLive = myLiveList.get(holder.getAdapterPosition());

        List<String> second = new ArrayList<>();
        for (int i = 0; i < 15; i++) {
            second.add("Item_ITem"+i);
        }


        holder.mTvTitle.setText(myLiveList.get(position));
//        holder.list.addAll(myLiveList.get(position));
        if (holder.chuShiRightAdapter == null) {
            holder.chuShiRightAdapter = new ChuShiRightAdapter(mContext, second, position);
            LinearLayoutManager layoutManage = new LinearLayoutManager(mContext);
            holder.rv_item.setLayoutManager(layoutManage);
//            holder.rvItemItem.addItemDecoration(new GridSpacingItemDecoration(2, 20, false));
            holder.rv_item.setAdapter(holder.chuShiRightAdapter);
        } else {
            holder.chuShiRightAdapter.setPosition(position);
            holder.chuShiRightAdapter.notifyDataSetChanged();
        }


  /*      if (myLive.getApplyAmount() == 0) {
            holder.img_add.setVisibility(View.VISIBLE);
            holder.layout_produce.setVisibility(View.GONE);
            holder.layout_guige.setVisibility(View.VISIBLE);
        } else {
            holder.layout_produce.setVisibility(View.VISIBLE);
            holder.img_add.setVisibility(View.GONE);
            holder.layout_guige.setVisibility(View.VISIBLE);
        }*/


    }

    @Override
    public int getItemCount() {
        return myLiveList.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        TextView mTvTitle;
        RecyclerView rv_item;
        ChuShiRightAdapter chuShiRightAdapter;
        private List<String> list = new ArrayList<>();

        public ViewHolder(View itemView) {
            super(itemView);
            mTvTitle = (TextView) itemView.findViewById(R.id.text_name);
            rv_item = itemView.findViewById(R.id.rv_item);
        }
    }


}
